import Vue from 'vue'
import VueRouter from 'vue-router'
import AluminumPriceList from '../views/AluminumPriceList.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/aluminum-prices'
  },
  {
    path: '/aluminum-prices',
    name: 'AluminumPriceList',
    component: AluminumPriceList,
    meta: { title: '铝价数据列表' }
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// 标题处理
router.beforeEach((to, from, next) => {
  document.title = to.meta.title ? `${to.meta.title} - 铝价数据系统` : '铝价数据系统'
  next()
})

export default router